//Pietras93OS
//x86
//pietras93@gmail.com
//


#include "include/x86.h"

void outportw(unsigned short port, int word)
{
   __asm__ __volatile__ ( "mov %0, %%dx    \n"
                          "mov %1, %%ax    \n"
                          "outw %%ax, %%dx \n"
                          : : "g" (port), "g" (word));
}

unsigned short inportw(int port)
{
   unsigned short ans = 0;
   __asm__ __volatile__ ( "mov %1, %%dx    \n"
                          "inw %%dx, %%ax  \n"
                          "mov %%ax, %0    \n"
                          : "=g" (ans)  : "g" (port));
   return ans;
}

void outportl(int port, unsigned long value)
{
   asm volatile("outl %0, %%dx" : : "a" (value) , "d" ((unsigned short)(port)));
}

unsigned long inportl(int port)
{
   unsigned long _tmp__;
   asm volatile("inl %%dx, %0" : "=a" (_tmp__) : "d" ((unsigned short)(port)));
   return _tmp__;
}
